export const mixin = {
	methods: {
		courseType(courseLevel) {
			let value = '';
			switch (courseLevel) {
				case 1:
					value = '初级';
					break;
				case 2:
					value = '中级';
					break;
				case 3:
					value = '高级';
					break;
			}
			return value;
		},
		courseNumber(number) {
			if (number == 0) {
				return "0";
			} else if (number > 999 && number <= 9999) {
				return (number / 1000).toFixed(1) + 'k';
			} else if (number > 9999 && number <= 99999) {
				return (number / 10000).toFixed(1) + 'w';
			} else if (number > 99999) {
				return "10w+";
			}
			return number;
		},
		getHeight(HeaderSearch, HomeTabs) {
			let searchHeight = 0;
			let tabsHeight = 0;
			let swiperHeight = 0;
			if (HeaderSearch) {
				//获取header_search高度
				let searchView = uni.createSelectorQuery().select(HeaderSearch);
				searchView
					.boundingClientRect((data) => {
						searchHeight = data.height;
					})
					.exec();
			}

			if (HomeTabs) {
				//获取home_tab高度
				let tabsView = uni.createSelectorQuery().select(HomeTabs);
				tabsView
					.boundingClientRect((data) => {
						tabsHeight = data.height;
					})
					.exec();
			}

			uni.getSystemInfo({
				success(res) {
					swiperHeight = res.windowHeight - searchHeight - tabsHeight;
				}
			});
			return swiperHeight;
		}
	}
}